#
# The MIT License (MIT)
#
# Copyright (c) 2016-2017 yutiansut/QUANTAXIS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


import threading

from six.moves import queue
from QUANTAXIS.QAUtil import QA_util_log_info,QA_Setting
from QA_Event import QA_Event, QA_EventDispatcher
from QA_Queue_standard import QA_Queue


"""
标准的QUANTAXIS事件方法,具有QA_Queue,QA_Event等特性,以及一些日志和外部接口
"""


class QA_Task():
    def __init__(self, Job:queue.Queue,  Event_: QA_Event, Dispatcher_: QA_EventDispatcher):
        self.Job = Job
        self.Task = QA_Queue(self.Job)

    def start_task(self, name: str, if_demon=False):
        self.Task.setName(name)
        self.Task.start()


if __name__ == '__main__':
    x1=queue.Queue()
    #X1=QA_Queue(x1)
    E1=QA_Event('x1')
    D1=QA_EventDispatcher()
    QA_Task(x1,E1,D1).start_task('xx')
    x1.put({'fn':print(x1)})
